from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

import time,random

url = "https://krdict.korean.go.kr/eng/mainAction"
""""""
service = Service("D:\\WPS Cloud Files\\msedgedriver.exe")
opt = Options()
opt.add_argument("--disable-blink-features=AutomationControlled")
opt.page_load_strategy = "eager"
# opt.page_load_strategy = "normal"
""""""
browser = webdriver.Edge(service=service,options=opt)

# browser.implicitly_wait(5)                       # 这就是一个不报错方法吗????

browser.maximize_window()
""""""
if __name__ == '__main__':
    browser.get(url)

    for i in range(5):
        """ 以下为固定格式"""
        locator = (By.CSS_SELECTOR,'#main > div > div.language_list > ul > li:nth-child(10) > a')
        """"""
        try:
            WebDriverWait(browser, 5).until(EC.presence_of_element_located(locator))
        except:
            print('未找到该页面')

        next_page = browser.find_element(By.CSS_SELECTOR,
                                         '#main > div > div.language_list > ul > li:nth-child(10) > a')
        next_page.click()

    time.sleep(1000)




























